﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class SJWH_SJWHList : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      txtRQ.Text = DateTime.Now.ToString("yyyyMM");
    }
    BindGrid();
  }

  protected void BindGrid()
  {
    string sSql = @"SELECT a.*,b.bqql BQQL2,F.YQXZ from (select a.*,B.BYBS SYBS,c.KHMC,D.KHJB,E.DWMC,C.IC FROM 
(select * from sjlr_cbsj where convert(varchar(6),cbsj,112)=@0) A 
left join (select * from sjlr_cbsj where convert(varchar(6),dateadd(month,1,cbsj),112)=@0) B on a.khid=b.khid 
left join jcxx_khxx c on a.khid=c.khid 
left join jcxx_khjb d on c.khjbid=d.khjbid  
left join jcxx_dw e on c.dwid=e.dwid ) a JOIN sjlr_bqql b
on a.cbsjid=b.cbsjid
join jcxx_yqxz f on b.yqxzid=f.yqxzid";
    SqlParameter[] cmdParams = { new SqlParameter("@0", SqlDbType.VarChar, 6) };
    cmdParams[0].Value = txtRQ.Text;
    DataSet ds = DbHelperSQL.Query(sSql, cmdParams);
    ASPxGridView1.DataSource = ds;
    ASPxGridView1.DataBind();
  }

  protected void btnQuery_Click(object sender, EventArgs e)
  {
    BindGrid();

  }
}
